<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script src="../script/vue.js"></script>
<script src="../script/dayjs.min.js"></script>
<body>
    <!-- 这里可以添加页面内容 -->
    <h2>格式化数据</h2>
    <div id="root">
        <span>原始数据:</span> {{startTIme}}<br>
        <span>方法格式化数据:</span> {{getFmtTime(startTIme, 'YYYY-MM-DD hh:mm:ss')}}<br>
        <span>格式化数据:</span> {{startTIme | formatDate('YYYY-MM-DD hh:mm:ss')}}
    </div>

</body>
<script>
    const app = new Vue({
        el: '#root',
        data: {
          startTIme: Date.now()
        },
        methods: {
            getFmtTime(val, fmt) {
                return dayjs(val).format(fmt)
            }
        },
        filters: {
            formatDate(val, fmt) {
                console.log(val, fmt);
               return dayjs(val).format(fmt)
            }
        }
    })
</script>


</html>
